﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace linkouqs.Gamekit {

    public class CharacterAbilityJumpAttack : CharacterAbility {

        [Range(1, 200)]
        public int damage = 20;
        
        [Range(0f, 10f)]
        [SerializeField]
        float m_CoolDownTime = 0.5f;

        int m_JumpAttackTimes;

        float m_CoolDownTimeCounter;

        public override bool CanStartAction() {

            if(m_JumpAttackTimes > 0) {
                return false;
            }

            if(m_CoolDownTimeCounter > 0f) {
                return false;
            }

            return base.CanStartAction();
        }

        public override void StartAction() {
            base.StartAction();
            m_CoolDownTimeCounter = m_CoolDownTime;
            m_JumpAttackTimes++;
            Character.Animator.SetTrigger("JumpAttack");
        }

        public void ResetJumpAttackTimes() {
            m_JumpAttackTimes = 0;
        }

        void FixedUpdate() {

            if (IsInAnimation) {
                return;
            }

            if (m_CoolDownTimeCounter > 0f) {
                m_CoolDownTimeCounter -= Time.fixedDeltaTime;
            }
        }

    }

}
